
<template>
  <div>
    <el-tabs  class="tabHead" v-model="taskSelectedTab">
      <el-tab-pane  label="业务基本信息" name="baseInfo">
        <BusinessInfoDialog ref="BusinessInfoDialog"></BusinessInfoDialog>
        <div v-html="title"></div>
      </el-tab-pane>
      <el-tab-pane label="货物明细" name="details">
        <BusinessProductInfo ref="BusinessProductInfo"></BusinessProductInfo>
      </el-tab-pane>
      <el-tab-pane label="扣重设置" name="deuctSeting">
        <BusinessDeductDialog ref="BusinessDeductDialog"></BusinessDeductDialog>
      </el-tab-pane>
      <el-tab-pane label="路耗设置" name="lossSeting">
        <BusinessLossDialog ref="BusinessLossDialog"></BusinessLossDialog>
      </el-tab-pane>
      <el-tab-pane label="磅单设置" name="weightSeting">
        <BusinessWeightTemplate ref="BusinessWeightTemplate"></BusinessWeightTemplate>
      </el-tab-pane>
      <el-tab-pane label="质量要求" name="ziliang">
        <BusinessProductQuatityIndex ref="BusinessProductQuatityIndex"></BusinessProductQuatityIndex>
      </el-tab-pane>
      <el-tab-pane label="数量调整" name="number">
        <BusinessAdjustDialog ref="BusinessAdjustDialog"></BusinessAdjustDialog>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
  import BusinessLossDialog from '@/components/dialog/businessLossDialog.vue'
  import BusinessInfoDialog from '@/components/dialog/businessInfoDialog.vue'
  import BusinessDeductDialog from '@/components/dialog/businessDeductDialog.vue'
  import BusinessAdjustDialog from '@/components/dialog/businessAdjustDialog.vue'
  import BusinessProductInfo from '@/components/dialog/businessProductInfo.vue'
  import BusinessProductQuatityIndex from '@/components/dialog/businessProductQuatityIndex.vue'
  import BusinessWeightTemplate from '@/components/dialog/businessWeightTemplate.vue'
  export default {
    components: {
      BusinessInfoDialog, // 业务基本信息
      BusinessDeductDialog, // 扣重设置
      BusinessAdjustDialog, // 数量调整
      BusinessProductInfo, // 货物明细
      BusinessWeightTemplate, // 磅单设置
      BusinessProductQuatityIndex, // 质量要求
      BusinessLossDialog // 路耗设置
    },
    data() {
      return {
        procInsId1:'',
        title: '<span style="font-size:20px"></span>',
        businessId: '',
        modelId: '',
        tableData: [],
        loading: false,
        dialogVisible: false,
        inputName: '',
        histoicFlowList: [],
        data: [],
        taskSelectedTab: "baseInfo",
        page: {
          pageSize: 10,
          pageNo: 1,
          total: 20
        }
      }
    },
    props: {
      businessId: {
        type: String,
        default: ''
      },
      formReadOnly: {
        type: Boolean,
        default: false
      },
      businessType: {
        type: Number
      }
    },
    watch: {
      // 例如：当前为调价审批表单，对应的是销售调价业务，表是：t_business_product
      // 这里的business就指的是t_business_product的一个主键ID
      'businessId': {
        handler(newVal) {
          if (this.businessId) {
            this.init(this.businessId)
          } else {
            this.$nextTick(() => {
              this.$refs.inputForm.resetFields()
            })
          }
        },
        immediate: true,
        deep: false
      }
    },
    methods: {
      init(businessId) {
        this.dialogVisible = true
        this.businessId = businessId
        // this.modelId = this.$parent.modelId
      },
      handleCurrentChange(e) {
        this.page.pageNo = e
        this.getCompanyList(this.page)
        console.log(e)
      },
      add() {
        this.$refs.editInfoDrawer.init('add')
      },

      openDialog() {
        this.$nextTick(() => {
          // 调用业务基本信息
          this.$refs['BusinessInfoDialog'].getInfo(this.businessId)
          // 路耗列表
          this.$refs['BusinessLossDialog'].noShow=true;
          this.$refs['BusinessLossDialog'].getLossList(this.businessId, this.modelId)
          // 扣重列表
          this.$refs['BusinessDeductDialog'].noShow=true;
          this.$refs['BusinessDeductDialog'].getList(this.businessId, this.modelId)
          // 数量调整列表
          this.$refs['BusinessAdjustDialog'].noShow=true;
          this.$refs['BusinessAdjustDialog'].getList(this.businessId)
          // 货物明细：左侧货物菜单数据
          this.$refs['BusinessProductInfo'].getProductList(this.businessId)
          // 质量要求：左侧货物菜单数据
           this.$refs['BusinessProductQuatityIndex'].noShow=true;
          this.$refs['BusinessProductQuatityIndex'].getProductQuatityIndexList(this.businessId)
          // 磅单设置: 获取模版select
          this.$refs['BusinessWeightTemplate'].noShow=true;
          this.$refs['BusinessWeightTemplate'].getList(this.businessId, this.modelId)
        })
      },
      tableRowClassName({
        row,
        rowIndex
      }) {
        if (rowIndex % 2 === 1) {
          return 'warning-row'
        } else {
          return 'success-row'
        }
      },
      handleClose(done) {
        done()
      },
      close() {},
      doSubmit() {}
    },
    mounted () {
      this.openDialog();
    }
  }
</script>
<style lang="scss" scoped>
  ::v-deep.tableDialog.el-dialog__wrapper {
    .el-dialog__body {
      padding-top: 0 !important;
    }
  }

  ::v-deep.tabHead {
    .el-tabs__header {
      margin-bottom: 20px;

      .el-tabs__item {
        font-size: 16px;
        padding: 0 10px;
      }
    }

    .el-tabs__content {
      height: 462px;
      overflow: auto;
    }
  }
</style>
